/* 移动端基础样式 */

/* ===== 响应式断点 ===== */
:root {
  --breakpoint-xs: 0;
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  
  /* 移动端尺寸标准 */
  --touch-target-size: 44px; /* 最小可触摸区域大小 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  
  /* 字体尺寸 */
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  
  /* 圆角尺寸 */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  
  /* 动画时间 */
  --transition-fast: 0.15s;
  --transition-normal: 0.25s;
  --transition-slow: 0.4s;
}

/* ===== 全局响应式设置 ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* 移除Safari点击高亮 */
  touch-action: manipulation; /* 优化触摸事件 */
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%; /* 防止iOS横屏字体变大 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--background-grey);
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===== 响应式容器 ===== */
.container {
  width: 100%;
  padding-right: 16px;
  padding-left: 16px;
  margin-right: auto;
  margin-left: auto;
}

/* 防止图片溢出容器 */
img {
  max-width: 100%;
  height: auto;
}

/* ===== 移动优先的布局工具 ===== */

/* 弹性布局容器 */
.flex-container {
  display: flex;
  flex-wrap: wrap;
}

.flex-column {
  flex-direction: column;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.flex-between {
  justify-content: space-between;
}

.flex-item {
  flex: 1;
  min-width: 0; /* 修复overflow问题 */
}

/* 网格布局 */
.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (min-width: 576px) {
  .grid-container {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 768px) {
  .grid-container {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* ===== 表单元素优化 ===== */
input, select, textarea, button {
  font-family: inherit;
  font-size: 16px; /* 防止iOS自动缩放 */
  border-radius: var(--border-radius-md);
}

/* 更大的触摸目标 */
button, 
.btn,
input[type="submit"],
input[type="button"] {
  min-height: var(--touch-target-size);
  padding: 10px 16px;
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  font-weight: 500;
  border-radius: var(--border-radius-md);
  touch-action: manipulation;
}

/* 文本输入框 */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
textarea,
select {
  display: block;
  width: 100%;
  min-height: var(--touch-target-size);
  padding: 8px 12px;
  border: 1px solid var(--divider);
  border-radius: var(--border-radius-md);
  background-color: var(--background-white);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none; /* 移除默认样式 */
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-blue);
  outline: none;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* 表单验证状态 */
input.is-valid,
textarea.is-valid,
select.is-valid {
  border-color: var(--success);
}

input.is-invalid,
textarea.is-invalid,
select.is-invalid {
  border-color: var(--error);
}

input.is-invalid:focus,
textarea.is-invalid:focus,
select.is-invalid:focus {
  box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.2);
}

/* 选择框特殊样式 */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

/* 表单组 */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

/* 表单布局 - 标签在上 */
.form-vertical .form-group {
  display: flex;
  flex-direction: column;
}

/* ===== 卡片样式 ===== */
.card {
  background-color: white;
  border-radius: var(--border-radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body {
  padding: 16px;
}

.card-footer {
  padding: 16px;
  border-top: 1px solid #eee;
  background-color: #fafafa;
}

/* ===== 列表样式 ===== */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-item {
  padding: 16px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  min-height: 56px; /* 更容易点击 */
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.list-item-subtitle {
  font-size: var(--font-size-sm);
  color: #666;
}

/* ===== 移动端特有组件 ===== */

/* 底部操作栏 */
.bottom-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  padding: 12px 16px;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* 添加安全区域边距，适配iPhone X及以上 */
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
}

/* 空状态 */
.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: #999;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--font-size-lg);
  margin-bottom: 8px;
}

.empty-state-description {
  font-size: var(--font-size-sm);
  max-width: 240px;
  margin: 0 auto;
}

/* 轻提示 */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 12px 20px;
  border-radius: var(--border-radius-lg);
  z-index: 1000;
  font-size: var(--font-size-sm);
  max-width: 90%;
  text-align: center;
}

/* 轻弹窗 */
.popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  overflow: hidden;
  z-index: 999;
  transform: translateY(100%);
  transition: transform var(--transition-normal);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.popup.active {
  transform: translateY(0);
}

.popup-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-title {
  font-weight: 500;
  font-size: var(--font-size-lg);
}

.popup-body {
  padding: 20px 16px;
  max-height: 70vh;
  overflow-y: auto;
}

/* 加载指示器 */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: #1976d2;
  animation: spinner 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes spinner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 页面过渡动画 */
.page-enter-active,
.page-leave-active {
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.page-enter,
.page-leave-to {
  opacity: 0;
  transform: translateX(20px);
}

/* 移动端下拉刷新指示器 */
.pull-refresh-indicator {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: height 0.2s;
}

/* 移动端适配工具类 */
.safe-area-top {
  padding-top: env(safe-area-inset-top, 0);
}

.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.hide-scrollbar {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.hide-scrollbar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* 媒体查询辅助工具 */
.visible-xs {
  display: block;
}

.hidden-xs {
  display: none;
}

@media (min-width: 576px) {
  .visible-xs {
    display: none;
  }
  
  .hidden-xs {
    display: block;
  }
}

/* 动画时间辅助类 */
.transition-normal {
  transition: all var(--transition-normal);
}

.transition-fast {
  transition: all var(--transition-fast);
}

/* 触摸涟漪效果 */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #000 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform .5s, opacity 1s;
}

.ripple:active::after {
  transform: scale(0, 0);
  opacity: .2;
  transition: 0s;
} 